﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace ETS_FinancialData_sync_toolsForServer
{

    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "账务同步服务端2.0.0~请勿关闭";
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            TcpServer tcpServer = new TcpServer();
            Console.WriteLine("正在启动服务，监听10100端口...");
            tcpServer.Start();
            Console.WriteLine("-------------------------------------");
            Json.DbHelper.getsqlconn();
            Console.WriteLine("正在检查数据库链接参数...");
            //Console.WriteLine(Json.DbHelper.Sqlconn);
            Console.WriteLine("-------------------------------------");
            Console.WriteLine("正在检索过滤规则...");
            Json.DbHelper.setupRulesDataTable();
            DataRow[] drs = Json.dt.Select();
            Console.WriteLine("-------------------------------------");
            Console.WriteLine("|编号|分馆名称|替换字符串|替换分公司|");
            for (int i = 0; i < drs.Length; i++)
            {
                Console.WriteLine("|" + drs[i]["id"] + "|" + drs[i]["fClubName"] + "|" + drs[i]["replaceString"] + "|" + drs[i]["replaceFclub"] + "|");
            }
            Console.WriteLine("-------------------------------------");
            Console.WriteLine("不走过滤规则的项");
            Console.WriteLine("-------------------------------------");
            Json.DbHelper.getFilteringRules();
            Thread.Sleep(500);
            string showtext = "付款：";
            foreach (var item in Json.paymentCodeArr)
            {
                showtext += "|" + item;
            }
          Console.WriteLine(showtext);
          Console.WriteLine("-------------------------------------");
            showtext = "财务：";
            foreach (var item in Json.kindaccCodeArr)
            {
                showtext += "|" + item;
            }
            Console.WriteLine(showtext);
            Console.WriteLine("-------------------------------------");
            Console.WriteLine("过滤规则检索成功！");
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine("账务服务启动成功！输入1按Enter键进入配置页面");
            Console.WriteLine("-------------------------------------------");
            string menu = Console.ReadLine();
            if (menu == "1")
            {
                Application.Run(new setup());
            }
            Console.WriteLine("按任意键退出账务同步服务......");
            Console.ReadKey();
        }
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        //[STAThread]
        //static void Main()
        //{
        //    Application.EnableVisualStyles();
        //    Application.SetCompatibleTextRenderingDefault(false);
        //    Application.Run(new ETS_FinancialData_sync_tools.server());
        //}
    }
}
